package weaver.splittable.biz.workflow;

import net.sf.jsqlparser.schema.Column;
import net.sf.jsqlparser.schema.Table;

import java.util.List;

public class STWorkflowWhereInfo {

    private String left;

    private String operator;

    private Object right;

    private Table leftTable;

    private Table rightTable;

    private List inItems;

    public STWorkflowWhereInfo(Column leftColumn, Object rightColumn, String operator) {
        this.left = leftColumn.getColumnName();
        this.operator = operator;
        this.leftTable = leftColumn.getTable();
        if (rightColumn instanceof Column) {
            this.right = ((Column) rightColumn).getColumnName();
            this.rightTable = ((Column) rightColumn).getTable();
        } else {
            this.right = rightColumn;
        }
    }

    public STWorkflowWhereInfo(Column leftColumn, String operator) {
        this.left = leftColumn.getColumnName();
        this.operator = operator;
        this.leftTable = leftColumn.getTable();
    }

    public STWorkflowWhereInfo(String left, String operator, Object right) {
        this.left = left;
        this.operator = operator;
        this.right = right;
    }

    public STWorkflowWhereInfo(String left, List<Object> inItems) {
        this.left = left;
        this.operator = "in";
        this.inItems = inItems;
    }

    public String getLeft() {
        return left;
    }

    public void setLeft(String left) {
        this.left = left;
    }

    public String getOperator() {
        return operator;
    }

    public void setOperator(String operator) {
        this.operator = operator;
    }

    public Object getRight() {
        return right;
    }

    public void setRight(String right) {
        this.right = right;
    }

    public Table getLeftTable() {
        return leftTable;
    }

    public void setLeftTable(Table leftTable) {
        this.leftTable = leftTable;
    }

    public Table getRightTable() {
        return rightTable;
    }

    public void setRightTable(Table rightTable) {
        this.rightTable = rightTable;
    }

    public void setRight(Object right) {
        this.right = right;
    }

    public List getInItems() {
        return inItems;
    }

    public void setInItems(List inItems) {
        this.inItems = inItems;
    }

    @Override
    public String toString() {
        return "WhereInfo{" +
                "left='" + left + '\'' +
                ", operator='" + operator + '\'' +
                ", right=" + right +
                ", leftTable=" + leftTable +
                ", rightTable=" + rightTable +
                ", inItems=" + inItems +
                '}';
    }
}
